from rest_framework import serializers
from .models import *



class MenuSerializer(serializers.ModelSerializer):

    class Meta:
        model = Menu
        fields = "__all__"

    def to_representation(self, instance):
        representation = super(MenuSerializer, self).to_representation(instance)
        representation['kinds'] = instance.kinds.name
        return representation


class KindSerializer(serializers.ModelSerializer):

    class Meta:
        model = Kind
        fields = "__all__"

    def to_representation(self, instance):
        representation = super(KindSerializer, self).to_representation(instance)
        representation['name'] = instance.name
        return representation


class ImageSerializer(serializers.ModelSerializer):

    class Meta:
        model = ImageList
        fields = "__all__"

    def to_representation(self, instance):
        representation = super(ImageSerializer, self).to_representation(instance)
        representation['name'] = instance.menus.name
        representation['image'] = str(instance.image)
        return representation